home *** CD-ROM | disk | FTP | other *** search
/ AppleScript - The Beta Release / AppleScript - The Beta Release.iso / Documentation / develop / Better Apple Event Coding / Code Samples / TESample.r < prev    next >
Encoding:
Text File  |  1992-10-16  |  8.0 KB  |  363 lines  |  [TEXT/MPS ]

  1. /*------------------------------------------------------------------------------------------
  2.  
  3.     Program:    CPlusTESample 2.0AE
  4.     File:        TESample.r
  5.     Uses:       TECommon.h
  6.  
  7.     by Andrew Shebanow
  8.     of Apple Macintosh Developer Technical Support
  9.     with modifications by Eric Berdahl
  10.  
  11.     Copyright © 1989-1990 Apple Computer, Inc.
  12.     Copyright © 1992 Eric Berdahl
  13.     All rights reserved.
  14.  
  15. ------------------------------------------------------------------------------------------*/
  16.  
  17. #include "SysTypes.r"
  18. #include "Types.r"
  19.  
  20. #include "TECommon.h"
  21.  
  22. resource 'vers' (1) {
  23.     0x02, 0x00, release, 0x00, verUS,
  24.     "2.00AE",
  25.     "2.00AE, Copyright © 1989-1990 Apple Computer, Inc. 1992 Eric Berdahl"
  26. };
  27.  
  28. /* we use an MBAR resource to conveniently load all the menus */
  29.  
  30. resource 'MBAR' (rMenuBar, preload) {
  31.     { mApple, mFile, mEdit, mFont, mFontSize, mStyle };        /* six menus */
  32. };
  33.  
  34.  
  35. resource 'MENU' (mApple, preload) {
  36.     mApple, textMenuProc,
  37.     0b1111111111111111111111111111101,    /* disable dashed line, enable About and DAs */
  38.     enabled, apple,
  39.     {
  40.         "About TESample…",
  41.             noicon, nokey, nomark, plain;
  42.         "-",
  43.             noicon, nokey, nomark, plain
  44.     }
  45. };
  46.  
  47. resource 'MENU' (mFile, preload) {
  48.     mFile, textMenuProc,
  49.     0b0000000000000000000100000000000,    /* enable Quit only, program enables others */
  50.     enabled, "File",
  51.     {
  52.         "New",
  53.             noicon, "N", nomark, plain;
  54.         "Open…",
  55.             noicon, "O", nomark, plain;
  56.         "-",
  57.             noicon, nokey, nomark, plain;
  58.         "Close",
  59.             noicon, "W", nomark, plain;
  60.         "Save",
  61.             noicon, "S", nomark, plain;
  62.         "Save As…",
  63.             noicon, nokey, nomark, plain;
  64.         "Revert",
  65.             noicon, nokey, nomark, plain;
  66.         "-",
  67.             noicon, nokey, nomark, plain;
  68.         "Page Setup…",
  69.             noicon, nokey, nomark, plain;
  70.         "Print…",
  71.             noicon, nokey, nomark, plain;
  72.         "-",
  73.             noicon, nokey, nomark, plain;
  74.         "Quit",
  75.             noicon, "Q", nomark, plain
  76.     }
  77. };
  78.  
  79. resource 'MENU' (mEdit, preload) {
  80.     mEdit, textMenuProc,
  81.     0b0000000000000000000000000000000,    /* disable everything, program does the enabling */
  82.     enabled, "Edit",
  83.     {
  84.         "Undo",
  85.             noicon, "Z", nomark, plain;
  86.         "-",
  87.             noicon, nokey, nomark, plain;
  88.         "Cut",
  89.             noicon, "X", nomark, plain;
  90.         "Copy",
  91.             noicon, "C", nomark, plain;
  92.         "Paste",
  93.             noicon, "V", nomark, plain;
  94.         "Clear",
  95.             noicon, nokey, nomark, plain;
  96.         "-",
  97.             noicon, nokey, nomark, plain;
  98.         "Select All",
  99.             noicon, "A", nomark, plain
  100.     }
  101. };
  102.  
  103. resource 'MENU' (mFont, preload) {
  104.     mFont, textMenuProc,
  105.     0b1111111111111111111111111111111,    /* enable everything */
  106.     enabled, "Font",
  107.     {
  108.     }
  109. };
  110.  
  111. resource 'MENU' (mFontSize, preload) {
  112.     mFontSize, textMenuProc,
  113.     0b1111111111111111111111111111111,    /* enable everything */
  114.     enabled, "Font Size",
  115.     {
  116.         "9 Point",
  117.             noicon, nokey, nomark, plain;
  118.         "10 Point",
  119.             noicon, nokey, nomark, plain;
  120.         "12 Point",
  121.             noicon, nokey, nomark, plain;
  122.         "14 Point",
  123.             noicon, nokey, nomark, plain;
  124.         "18 Point",
  125.             noicon, nokey, nomark, plain;
  126.         "24 Point",
  127.             noicon, nokey, nomark, plain;
  128.     }
  129. };
  130.  
  131. resource 'MENU' (mStyle, preload) {
  132.     mStyle, textMenuProc,
  133.     0b1111111111111111111111111111101,    /* enable everything but the dashed line */
  134.     enabled, "Style",
  135.     {
  136.         "Plain",
  137.             noicon, "P", nomark, plain;
  138.         "-",
  139.             noicon, nokey, nomark, plain;
  140.         "Bold",
  141.             noicon, "B", nomark, bold;
  142.         "Italic",
  143.             noicon, "I", nomark, italic;
  144.         "Underline",
  145.             noicon, "U", nomark, underline;
  146.         "Outline",
  147.             noicon, nokey, nomark, outline;
  148.         "Shadow",
  149.             noicon, nokey, nomark, shadow;
  150.     }
  151. };
  152.  
  153.  
  154. /* this ALRT and DITL are used as an About screen */
  155.  
  156. resource 'ALRT' (rAboutAlert, purgeable) {
  157.     {40, 20, 160, 337 }, rAboutAlert, {
  158.         OK, visible, silent;
  159.         OK, visible, silent;
  160.         OK, visible, silent;
  161.         OK, visible, silent
  162.     };
  163. };
  164.  
  165. resource 'DITL' (rAboutAlert, purgeable) {
  166.     { /* array DITLarray: 5 elements */
  167.         /* [1] */
  168.         {88, 227, 108, 305},
  169.         Button {
  170.             enabled,
  171.             "OK"
  172.         },
  173.         /* [2] */
  174.         {8, 8, 24, 305 },
  175.         StaticText {
  176.             disabled,
  177.             "MultiFinder-Aware C++ TextEdit Application"
  178.         },
  179.         /* [3] */
  180.         {32, 8, 48, 305},
  181.         StaticText {
  182.             disabled,
  183.             "Copyright © 1989-1990 Apple Computer, Inc."
  184.         },
  185.         /* [4] */
  186.         {56, 8, 72, 305},
  187.         StaticText {
  188.             disabled,
  189.             "Brought to you by:"
  190.         },
  191.         /* [5] */
  192.         {80, 24, 112, 222},
  193.         StaticText {
  194.             disabled,
  195.             "Macintosh Developer Technical Support"
  196.         }
  197.     }
  198. };
  199.  
  200.  
  201. resource 'WIND' (rDocWindow, preload, purgeable) {
  202.     {64, 60, 314, 460},
  203.     zoomDocProc, invisible, goAway, 0x0, "untitled"
  204. };
  205.  
  206.  
  207. resource 'CNTL' (rVScroll, preload, purgeable) {
  208.     {-1, 385, 236, 401},
  209.     0, visible, 0, 0, scrollBarProc, 0, ""
  210. };
  211.  
  212.  
  213. resource 'CNTL' (rHScroll, preload, purgeable) {
  214.     {235, -1, 251, 386},
  215.     0, visible, 0, 0, scrollBarProc, 0, ""
  216. };
  217.  
  218. resource 'STR#' (kTEDocErrStrings, purgeable) {
  219.     {
  220.     "Not enough memory to run TESample.";
  221.     "Not enough memory to do Cut.";
  222.     "Error during Cut.";
  223.     "Error during Copy.";
  224.     "Cannot exceed 32,000 characters with Paste.";
  225.     "Not enough memory to do Paste.";
  226.     "Cannot create window for document.";
  227.     "Document cannot exceed 32,000 characters.";
  228.     "Error during Paste.";
  229.     "Cannot open an unknown file type."
  230.     }
  231. };
  232.  
  233. /* here is the quintessential MultiFinder friendliness device, the SIZE resource */
  234.  
  235. resource 'SIZE' (-1) {
  236.     dontSaveScreen,
  237.     acceptSuspendResumeEvents,
  238.     enableOptionSwitch,
  239.     canBackground,        /* we can background; we don't currently, but our sleep value */
  240.                         /* guarantees we don't hog the Mac while we are in the background */
  241.     multiFinderAware,    /* this says we do our own activate/deactivate; don't fake us out */
  242.     backgroundAndForeground, /* this is definitely not a background-only application! */
  243.     dontGetFrontClicks,    /* change this is if you want "do first click" behavior like the Finder */
  244.     ignoreChildDiedEvents,
  245.     is32BitCompatible,
  246.     isHighLevelEventAware,
  247.     localAndRemoteHLEvents,
  248.     notStationeryAware,
  249.     dontUseTextEditServices,
  250.     reserved,
  251.     reserved,
  252.     reserved,
  253.     kPrefSize * 1024,
  254.     kMinSize * 1024
  255. };
  256.  
  257.  
  258. type 'MOOT' as 'STR ';
  259.  
  260.  
  261. resource 'MOOT' (0) {
  262.     "MultiFinder-Aware TextEdit Sample Application"
  263. };
  264.  
  265.  
  266. resource 'BNDL' (128) {
  267.     'MOOT',
  268.     0,
  269.     {
  270.         'ICN#',
  271.         {
  272.             0, 128;
  273.             1, 129
  274.         },
  275.         'FREF',
  276.         {
  277.             0, 128;
  278.             1, 129
  279.         }
  280.     }
  281. };
  282.  
  283.  
  284. resource 'FREF' (128) {
  285.     'APPL',
  286.     0,
  287.     ""
  288. };
  289.  
  290.  
  291. resource 'ICN#' (128) {
  292.     { /* array: 2 elements */
  293.         /* [1] */
  294.         $"04 30 40 00 0A 50 A0 00 0B 91 10 02 08 22 08 03"
  295.         $"12 24 04 05 20 28 02 09 40 10 01 11 80 0C 00 A1"
  296.         $"80 03 FF C2 7E 00 FF 04 01 00 7F 04 03 00 1E 08"
  297.         $"04 E0 00 0C 08 E0 00 0A 10 E0 00 09 08 C0 00 06"
  298.         $"04 87 FE 04 02 88 01 04 01 88 00 84 00 88 00 44"
  299.         $"00 88 00 44 00 88 00 C4 01 10 01 88 02 28 03 10"
  300.         $"01 C4 04 E0 00 02 08 00 73 BF FB EE 4C A2 8A 2A"
  301.         $"40 AA AA EA 52 AA AA 24 5E A2 8A EA 73 BE FB 8E",
  302.         /* [2] */
  303.         $"04 30 40 00 0E 70 E0 00 0F F1 F0 02 0F E3 F8 03"
  304.         $"1F E7 FC 07 3F EF FE 0F 7F FF FF 1F FF FF FF BF"
  305.         $"FF FF FF FE 7F FF FF FC 01 FF FF FC 03 FF FF F8"
  306.         $"07 FF FF FC 0F FF FF FE 1F FF FF FF 0F FF FF FE"
  307.         $"07 FF FF FC 03 FF FF FC 01 FF FF FC 00 FF FF FC"
  308.         $"00 FF FF FC 00 FF FF FC 01 FF FF F8 03 EF FF F0"
  309.         $"01 C7 FC E0 00 03 F8 00 73 BF FB EE 7F BE FB EE"
  310.         $"7F BE FB EE 7F BE FB E4 7F BE FB EE 73 BE FB 8E"
  311.     }
  312. };
  313.  
  314. resource 'FREF' (129) {
  315.     'TEXT',
  316.     1,
  317.     ""
  318. };
  319.  
  320.  
  321. resource 'ICN#' (129) {
  322.     {    /* array: 2 elements */
  323.         /* [1] */
  324.         $"FFFF FFFF 8A50 0001 8B97 7F73 8820 0003"
  325.         $"922F 77C5 A020 0009 C011 EF11 800C 0021"
  326.         $"8003 FFC3 FE00 FF05 8100 7F05 8100 1E09"
  327.         $"B8E0 0009 80E0 0009 BCE0 0009 80C0 0005"
  328.         $"9C87 FE05 8088 0105 BC8B E085 8088 0045"
  329.         $"B08B 7845 8088 0045 9D13 DC89 8220 0111"
  330.         $"B1CF 6EE1 8000 0001 F3BF FBEF CCA2 8A2B"
  331.         $"C0AA AAEB D2AA AA25 DEA2 8AEB FFFF FFFF",
  332.         /* [2] */
  333.         $"FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF"
  334.         $"FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF"
  335.         $"FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF"
  336.         $"FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF"
  337.         $"FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF"
  338.         $"FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF"
  339.         $"FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF"
  340.         $"FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF"
  341.     }
  342. };
  343.  
  344. resource 'aedt' (100) {            // Minimum for AppleEvent aware application
  345.     {
  346.     'aevt', 'oapp', cFinderNew;
  347.     'aevt', 'odoc', cFinderOpen;
  348.     'aevt', 'pdoc', cFinderPrint;
  349.     'aevt', 'quit', cFinderQuit;
  350.     }
  351. };
  352.  
  353.  
  354. resource 'aedt' (101) {            // Events added for our Object Model sample code
  355.     {
  356.     'aevt', 'clos', cClose;
  357.     'aevt', 'save', cSave;
  358.     'aevt', 'nobj', cNewElement;
  359.     'aevt', 'getd', cGetData;
  360.     'aevt', 'setd', cSetData;
  361.     }
  362. };
  363.